<template>
	<el-dialog title="选择归属类型" :visible.sync="dialogVisible" size="small" :close-on-click-modal="false" :close-on-press-escape="false" :before-close="off">
		  <el-form label-width="150px" >
		  <el-row :span="24">
		  	<el-form-item label="归属类型" label-width="150px" :span="24">
				<el-select v-model="ownerflag"  placeholder="司机/乘客/公共" clearable value-key="value" size="small" style="width:80%">
					<el-option v-for="item in ownerFlagOptions" :key="item.value" :label="item.value +  '-' + item.name" :value="item"></el-option>
				</el-select>
			</el-form-item>
		  </el-row>
		</el-form>
		  <span slot="footer" class="dialog-footer">
			   <el-button @click="off">取 消</el-button>
			   <el-button type="success" @click="select">确 定</el-button>
		  </span>
	</el-dialog>
</template>

<script>

  export default {
	data() {
		return {
			dialogVisible: true,
      ownerflag : '',
			currentRiskCode : '',
			currentItemCode : '',
      ownerFlagOptions : [
        {name: "司机",value:"0"},
        {name: "乘客",value:"1"},
        {name: "公共",value:"2"},
      ],
		}
	},
	mounted() {
		this.currentRiskCode = this.$parent.currentRiskCode;
		this.currentItemCode = this.$parent.currentItemCode;
    if (typeof this.currentRiskCode !== 'undefined') {
      this.ownerFlagOptions.push({name: "司机或乘客",value:"3"});
    }
	},
	methods: {
		select() {
      if (this.ownerflag === null || this.ownerflag === '') {
        this.$parent.tempOwnerFlag = '';
      } else {
			  this.$parent.tempOwnerFlag = this.ownerflag.value + '-' + this.ownerflag.name;
      }
      if (typeof this.currentRiskCode !== 'undefined') {
			  this.$parent.tempOwnerFlagId = 'ownerflag'+this.currentRiskCode;
      }
      if (typeof this.currentItemCode !== 'undefined') {
			  this.$parent.tempOwnerFlagId = 'ownerflag'+this.currentItemCode;
      }
			this.off();
		},
		off() {
			this.$parent.showOwnerFlagSelect = false;
		}
	}
  }
</script>
